/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-03-30
 * Time: 14:24
 */
class Student implements Comparable<Student> {
    String name;    // 学生姓名
    int age;        // 学生年龄
    double score;   // 考试成绩

    // 构造方法：创建学生对象时初始化数据
    public Student(String name, int age, double score) {
        this.name = name; // 给name字段赋值
        this.age = age;// 给age字段赋值
        this.score = score;// 给score字段赋值
    }

    // 重写toString方法：方便打印学生信息
    @Override
    public String toString() {
        return "[" + this.name + "|" + this.age + "|" + this.score + "]";
    }

    @Override
    // 实现Comparable接口的compareTo方法
    public int compareTo(Student o) {
        return this.age - o.age;
    }
}
